package net.studou.interceptor;

import net.studou.exception.SecretException;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class SystemExceptionInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = 1358600090729208361L;
	private Logger log = Logger.getLogger(SystemExceptionInterceptor.class);

	public String intercept(ActionInvocation invocation) {
		String result;
		try {
			result = invocation.invoke();
		} catch (SecretException e) {
			result = SecretLog.log(invocation, log, e);
		} catch (Exception e) {
			result = "error";
			log.error("System exception", e);
		}
		return result;
	}
}